﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Stats.aspx.cs" Inherits="Stats" Title="Статистические данные по работе сетей шифрованной документальной связи" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <div id="stats-left">
        <asp:RadioButtonList ID="rblStatType" runat="server" Width="220px" 
            AutoPostBack="True" OnSelectedIndexChanged="rblStatType_SelectedIndexChanged" 
            Visible="False">
            <asp:ListItem Selected="True">Данные по сетям связи</asp:ListItem>
            <asp:ListItem Value="Д в ЦПУ">Доклад в ЦПУ</asp:ListItem>
        </asp:RadioButtonList>
        <asp:Label ID="Label2" runat="server" Text="Данные по сетям связи"></asp:Label>
    <asp:DropDownList ID="ddlTypeQuery" runat="server" AutoPostBack="True" 
            onselectedindexchanged="ddlTypeQuery_SelectedIndexChanged" Width="220px">
        <asp:ListItem>за указанную дату</asp:ListItem>
        <asp:ListItem>за период с</asp:ListItem>
    </asp:DropDownList>
    <asp:Calendar ID="cldrDateStart" runat="server" BackColor="White" 
        BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" 
        DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" 
        ForeColor="#003399" Height="200px" Width="220px" SelectedDate="1998-05-01" 
            ToolTip="начальная дата" VisibleDate="1998-05-01" OnSelectionChanged="cldrDateStart_SelectionChanged">
        <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
        <WeekendDayStyle BackColor="#CCCCFF" />
        <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
        <OtherMonthDayStyle ForeColor="#999999" />
        <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
        <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
        <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" 
            Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
    </asp:Calendar>
        <asp:Label ID="Label1" runat="server" Text="по" Visible="False"></asp:Label>
    <asp:Calendar ID="cldrDateStop" runat="server" BackColor="White" 
        BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" 
        DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" 
        ForeColor="#003399" Height="200px" Width="220px" Visible="False" 
            SelectedDate="1998-05-05" ToolTip="конечная дата" VisibleDate="1998-05-05" OnSelectionChanged="cldrDateStart_SelectionChanged">
        <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
        <WeekendDayStyle BackColor="#CCCCFF" />
        <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
        <OtherMonthDayStyle ForeColor="#999999" />
        <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
        <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
        <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" 
            Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
    </asp:Calendar>
        <asp:Button ID="btnStatReport" runat="server" 
            Text="Создать отчет" Width="160px" OnClick="Button1_Click" Visible="False" />
    </div>
    <div id="stats-right">
        <asp:SqlDataSource ID="dsStatsEP" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AtlasDB %>" 
            SelectCommand="SELECT statistica.address,
       stat_elements.inform,
       sum(statistica.calls_pered) as calls_pered,
       sum(statistica.calls_prin) as calls_prin,
       sum(statistica.peredb) as peredb,
       sum(CAST(statistica.prinb as BIGINT))/1024 as prinb
FROM statistica,
     stat_elements
WHERE (statistica.TypeStat = 0) AND
      (statistica.address = stat_elements.address_x_121) AND
      (dbegin_stat between @dbegin_1 and @dbegin_2)
GROUP BY
  address, inform" 
            UpdateCommand="UPDATE statistica &#13;&#10;SET calls_pered = @calls_pered, peredb = @peredb*1024, calls_prin = @calls_prin, prinb = @prinb*1024&#13;&#10;WHERE (dbegin_stat = @dbegin_stat) and (address = @address)" 
            ProviderName="<%$ ConnectionStrings:AtlasDB.ProviderName %>">
            <SelectParameters>
                <asp:ControlParameter ControlID="cldrDateStart" DefaultValue="" Name="dbegin_1" PropertyName="SelectedDate" Type="DateTime" />
                <asp:ControlParameter ControlID="cldrDateStop" Name="dbegin_2" PropertyName="SelectedDate" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="calls_pered" />
                <asp:Parameter Name="peredb" />
                <asp:Parameter Name="calls_prin" />
                <asp:Parameter Name="prinb" />
                <asp:ControlParameter ControlID="cldrDateStart" Name="dbegin_stat" PropertyName="SelectedDate" />
                <asp:Parameter Name="address" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dsStatsHosts" runat="server" ConnectionString="<%$ ConnectionStrings:AtlasDB %>" SelectCommand="SELECT &#13;&#10;       stat_elements.inform,&#13;&#10;       sum(statistica.calls_pered) as calls_pered,&#13;&#10;       sum(statistica.calls_prin) as calls_prin,&#13;&#10;       sum(CAST(statistica.peredb as BIGINT))/1024 as peredb,&#13;&#10;       sum(CAST(statistica.prinb as BIGINT))/1024 as prinb&#13;&#10;FROM statistica,&#13;&#10;     stat_elements&#13;&#10;WHERE (statistica.TypeStat = 1) AND&#13;&#10;      (statistica.address = stat_elements.address_x_121) AND&#13;&#10;      (dbegin_stat between @dbegin_1 and @dbegin_2)&#13;&#10;GROUP BY&#13;&#10;  inform">
            <SelectParameters>
                <asp:ControlParameter ControlID="cldrDateStart" DefaultValue="" Name="dbegin_1" PropertyName="SelectedDate" />
                <asp:ControlParameter ControlID="cldrDateStop" Name="dbegin_2" PropertyName="SelectedDate" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dsStatsFR" runat="server" ConnectionString="<%$ ConnectionStrings:AtlasDB %>" SelectCommand="SELECT&#13;&#10;       statistica.address,&#13;&#10;       stat_elements.inform,&#13;&#10;       sum(CAST(statistica.peredb as BIGINT))/1024 as peredb&#13;&#10;FROM statistica,&#13;&#10;     stat_elements&#13;&#10;WHERE (statistica.TypeStat = 4) AND&#13;&#10;      (statistica.address = stat_elements.address_x_121) AND&#13;&#10;      (dbegin_stat between @dbegin_1 and @dbegin_2)&#13;&#10;GROUP BY&#13;&#10;  address, inform" UpdateCommand="UPDATE statistica &#13;&#10;SET peredb = @peredb*1024&#13;&#10;WHERE (dbegin_stat = @dbegin_stat) and (address = @address)">
            <UpdateParameters>
                <asp:Parameter Name="peredb" DefaultValue="" />
                <asp:ControlParameter ControlID="cldrDateStart" Name="dbegin_stat" PropertyName="SelectedDate" />
                <asp:Parameter Name="address" DefaultValue="11350" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="cldrDateStart" DefaultValue="" Name="dbegin_1" PropertyName="SelectedDate" />
                <asp:ControlParameter ControlID="cldrDateStop" Name="dbegin_2" PropertyName="SelectedDate" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dsStatsEP_SNG" runat="server" ConnectionString="<%$ ConnectionStrings:AtlasDB %>" SelectCommand="SELECT statistica.address,&#13;&#10;       stat_elements.inform,&#13;&#10;       sum(statistica.calls_pered) as calls_pered,&#13;&#10;       sum(statistica.calls_prin) as calls_prin,&#13;&#10;       sum(CAST(statistica.peredb as BIGINT))/1024 as peredb,&#13;&#10;       sum(CAST(statistica.prinb as BIGINT))/1024 as prinb&#13;&#10;FROM statistica,&#13;&#10;     stat_elements&#13;&#10;WHERE (statistica.TypeStat = 2) AND&#13;&#10;      (statistica.address = stat_elements.address_x_121) AND&#13;&#10;      (dbegin_stat between @dbegin_1 and @dbegin_2)&#13;&#10;GROUP BY&#13;&#10;  address, inform" UpdateCommand="UPDATE statistica &#13;&#10;SET calls_pered = @calls_pered, peredb = @peredb*1024, calls_prin = @calls_prin, prinb = @prinb*1024&#13;&#10;WHERE (dbegin_stat = @dbegin_stat) and (address = @address)">
            <UpdateParameters>
                <asp:Parameter Name="calls_pered" />
                <asp:Parameter Name="peredb" />
                <asp:Parameter Name="calls_prin" />
                <asp:Parameter Name="prinb" />
                <asp:ControlParameter ControlID="cldrDateStart" Name="dbegin_stat" PropertyName="SelectedDate" />
                <asp:Parameter Name="address" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="cldrDateStart" DefaultValue="" Name="dbegin_1" PropertyName="SelectedDate" />
                <asp:ControlParameter ControlID="cldrDateStop" Name="dbegin_2" PropertyName="SelectedDate" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:MultiView ID="mvStats" runat="server" ActiveViewIndex="0" EnableTheming="False">
            <asp:View ID="vStats" runat="server">
        Статистические данные по работе сетей шифрованной документальной связи
        <br/>
        <asp:Label ID="lbHeader" runat="server" Font-Bold="True" Text="за период с 21:00 по 21:00" Font-Overline="False" Font-Underline="False"></asp:Label>
        <asp:GridView ID="gvStatsEP" runat="server" CellPadding="4" ForeColor="Black" AutoGenerateColumns="False" Caption='Электронные почтамты "Атлас":' CaptionAlign="Left" Font-Bold="False" CellSpacing="1" DataSourceID="dsStatsEP" OnDataBound="gvStatsEP_DataBound">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="inform" HeaderText="Почтамт" SortExpression="address" ReadOnly="True" />
                <asp:BoundField DataField="address" HeaderText="Адрес" SortExpression="address" 
                    ReadOnly="True" />
                <asp:BoundField DataField="calls_prin" HeaderText="Принято (шт.)" 
                    SortExpression="calls_prin" />
                <asp:BoundField DataField="peredb" HeaderText="Срочных (шт.)" 
                    SortExpression="peredb" />
                <asp:BoundField DataField="calls_pered" HeaderText="Ошибок (шт.)" 
                    SortExpression="calls_pered" />
                <asp:BoundField DataField="prinb" HeaderText="Объем (Кб)" 
                    SortExpression="prinb" />
            </Columns><RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:Label ID="lbStatsEP" runat="server" Text='Итого по ЭП "Атлас":' Font-Bold="False"></asp:Label>
                &nbsp;
        <asp:GridView ID="gvStatsHosts" runat="server" CellPadding="4" 
            DataSourceID="dsStatsHosts" ForeColor="Black" AutoGenerateColumns="False" 
                    Caption='Хосты X.25:' CaptionAlign="Left" Font-Bold="False" CellSpacing="1" 
                    OnDataBound="gvStatsHosts_DataBound" Width="420px" Visible="False">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="inform" HeaderText="Направление" SortExpression="address" />
                <asp:BoundField DataField="calls_pered" HeaderText="Вызовы" SortExpression="calls_pered" />
                <asp:BoundField DataField="peredb" HeaderText="Передано(Кб)" SortExpression="peredb" HtmlEncode="False" />
                <asp:BoundField DataField="prinb" HeaderText="Принято(Кб)" SortExpression="prinb" />
            </Columns>
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:Label ID="lbStatsHosts" runat="server" Text="Итого по хостам:" Font-Bold="False" 
                    Visible="False"></asp:Label>&nbsp;
        <br />
        <asp:GridView ID="gvStatsFR" runat="server" CellPadding="4" 
            DataSourceID="dsStatsFR" ForeColor="Black" AutoGenerateColumns="False" Caption='FR-сеть (объем данных по всем портам Alcatel, кроме X.400):' CaptionAlign="Left" Font-Bold="False" CellSpacing="1" OnDataBound="gvStatsFR_DataBound" Width="420px">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="inform" HeaderText="Направление"></asp:BoundField>
                <asp:BoundField DataField="address" HeaderText="Адрес" Visible="False" />
                <asp:BoundField DataField="peredb" HeaderText="Итого (Мб)"></asp:BoundField>
                <asp:CommandField ShowEditButton="True" UpdateText="OK" />
            </Columns>
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
                <asp:Label ID="lbTotalAtlas" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="White"
                    Text='Итого по сети "АТЛАС": 0 Мб'></asp:Label><br />
        <asp:GridView ID="gvStatsEP_SNG" runat="server" CellPadding="4" ForeColor="Black" AutoGenerateColumns="False" Caption='Электронный почтамт "Атлас-СНГ":' CaptionAlign="Left" Font-Bold="False" CellSpacing="1" DataSourceID="dsStatsEP_SNG">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="inform" HeaderText="Почтамт" SortExpression="address" ReadOnly="True" />
                <asp:BoundField DataField="address" HeaderText="Адрес" SortExpression="address" />
                <asp:BoundField DataField="calls_prin" HeaderText="Принято (шт)" 
                    SortExpression="calls_prin" />
                <asp:BoundField DataField="peredb" HeaderText="Срочных (шт)" 
                    SortExpression="peredb" />
                <asp:BoundField DataField="calls_pered" HeaderText="Ошибок (шт)" 
                    SortExpression="calls_pered" />
                <asp:BoundField DataField="prinb" HeaderText="Объем (Кб)" 
                    SortExpression="prinb" />
            </Columns>
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:Label ID="lbStatsEP_SNG" runat="server" Font-Bold="False" Text='Итого по ЭП "Атлас-СНГ":' Visible="False"></asp:Label><br />
                &nbsp;
        <br />
            </asp:View>
            <asp:View ID="vReportCPU" runat="server">
                Доклад в ЦПУ<br />
                &nbsp;
                <br />
                &nbsp;
            </asp:View>        
        </asp:MultiView>
        <a onclick="javascript:print(document)" href="#">отправить на печать</a>
    </div>
</asp:Content>

